home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine PD Edition 0
/
Amoszine PD Edition 0.adf
/
SOURCE_CODE
/
4PlrAdapter.AMOS
/
4PlrAdapter.amosSourceCode
Wrap
AMOS Source Code
|
1993-02-25
|
4KB
|
113 lines
Rem
Rem Joystick Port Extender
Rem Routine
Rem By Digital Ninja
Rem
'
Rem THIS declaration is important!
Dim LEE(1)
'
Rem Now you can add another two joysticks to your games by
Rem using a Parallel 4 Player Adapter and this Routine!
'
Rem To use the routine, GOSUB EXT in a control routine or
Rem main loop, then use the following rules:
Rem
Rem LEE(0) = Joystick Three
Rem LEE(1) = Joystick Four
Rem
Rem The value returned from these are identical to those
Rem you found find in the AMOS command Joy(0) and Joy(1).
Rem
Rem Example:
Rem
Rem When dealing with joystick 3, use LEE(0)
Rem When dealing with joystick 4, use LEE(1)
Rem and look for:
Rem
Rem 1 - UP
Rem 2 - DOWN
Rem 4 - LEFT
Rem 8 - RIGHT
Rem 16 - FIRE
Rem
Rem because these values add together when crossed:
Rem
Rem 6 = Down and Left (Diagonal)
Rem 17 = Up and Fire
Rem 24 = Right and Fire
Rem 5 = Up and Left (Diagonal)
Rem
Rem (see AMOS manual for an explanation of this method!)
'
Rem When you wish to use this routine in your code, extract
Rem the EXT subroutine from this program. Place it at the
Rem end of your code. Now enter a line at the very start
Rem of your code to settup a small array:
Rem
Rem DIM LEE(1)
Rem
Rem Now place the command, GOSUB EXT in your main code and
Rem everytime your program passes the line Gosub Ext, the
Rem joysticks will be read and their positions will be put
Rem in LEE(0) and LEE(1) for use.
'
Rem A small program to show it working!
'
Flash Off : Curs Off : Pen 1 : Paper 0 : Cls 0 : Colour 1,$D0
Do
'
Gosub EXT : Rem This grabs the data from the joysticks
'
Locate 5,5
Print "Joystick Three = ";
'
If LEE(0)=0 : Print "Not moving! " : End If
If LEE(0)=1 : Print "Up " : End If
If LEE(0)=2 : Print "Down " : End If
If LEE(0)=4 : Print "Left " : End If
If LEE(0)=8 : Print "Right " : End If
If LEE(0)=16 : Print "Fire " : End If
If LEE(0)=5 : Print "Up/Left " : End If
If LEE(0)=6 : Print "Down/Left " : End If
If LEE(0)=9 : Print "Up/Right " : End If
If LEE(0)=10 : Print "Down/Right " : End If
If LEE(0)>16 : Print "Fire Direction" : End If
'
Locate 5,7
Print "Joystick Four = ";
'
If LEE(1)=0 : Print "Not moving! " : End If
If LEE(1)=1 : Print "Up " : End If
If LEE(1)=2 : Print "Down " : End If
If LEE(1)=4 : Print "Left " : End If
If LEE(1)=8 : Print "Right " : End If
If LEE(1)=16 : Print "Fire " : End If
If LEE(1)=5 : Print "Up/Left " : End If
If LEE(1)=6 : Print "Down/Left " : End If
If LEE(1)=9 : Print "Up/Right " : End If
If LEE(1)=10 : Print "Down/Right " : End If
If LEE(1)>16 : Print "Fire Direction" : End If
'
Loop
'
'
Rem This routine is Freeware and you may freely use this
Rem in your own code! Enjoy!
'
EXT:
'
LEE(0)=0
If(Peek($BFE101) and %1)=0 : LEE(0)=1 : End If
If(Peek($BFE101) and %10)=0 : LEE(0)=2 : End If
If(Peek($BFE101) and %100)=0 : LEE(0)=LEE(0)+4 : End If
If(Peek($BFE101) and %1000)=0 : LEE(0)=LEE(0)+8 : End If
If(Peek($BFD000) and %100)=0 : LEE(0)=LEE(0)+16 : End If
LEE(1)=0
If(Peek($BFE101) and %10000)=0 : LEE(1)=1 : End If
If(Peek($BFE101) and %100000)=0 : LEE(1)=2 : End If
If(Peek($BFE101) and %1000000)=0 : LEE(1)=LEE(1)+4 : End If
If(Peek($BFE101) and %10000000)=0 : LEE(1)=LEE(1)+8 : End If
If(Peek($BFD000) and %1)=0 : LEE(1)=LEE(1)+16 : End If
'
Return